//
//  ViewController.m
//  13-简书
//
//  Created by dllo on 16/8/1.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "ViewController.h"
#import "YMJTableViewCell.h"
#import "myModel.h"
#import "CarouseFigure.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) UIView *myView;
@property (nonatomic, strong) NSMutableArray *myArray;
@property (nonatomic, strong) NSMutableArray *headArray;
@property (nonatomic, strong) CarouseFigure *carouseFigure;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
//    self.myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 414, 200)];
//    _myView.backgroundColor = [UIColor redColor];
//    _myView.layer.borderColor = [UIColor yellowColor].CGColor;
//    _myView.layer.borderWidth = 1;
//    self.tableView.tableHeaderView = _myView;
    // 自己的数据
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Property List" ofType:@"plist"];
    NSDictionary *dataDic = [NSDictionary dictionaryWithContentsOfFile:path];
    _myArray = [NSMutableArray array];
    for (NSDictionary *dic in dataDic[@"data"]) {
        myModel *model = [[myModel alloc] init];
        [model setValuesForKeysWithDictionary:dic];
        [_myArray addObject:model];
    }
    // 录播图
    _headArray = [NSMutableArray arrayWithArray:dataDic[@"headImage"]];
    NSLog(@"%@",_headArray);
    _carouseFigure = [CarouseFigure creatCarouseFigureWithFrame:CGRectMake(0, 0, 414, 200) imageArray:_headArray];

//    [self.view addSubview:_carouseFigure];
    self.tableView.tableHeaderView = _carouseFigure;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _myArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YMJTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"1"];
    myModel *model = _myArray[indexPath.row];
    
    cell.touxiang.image = [UIImage imageNamed:model.image_person];
    cell.nicheng.text = model.name;
    cell.shijian.text = model.time;
    cell.biaoti.text = model.title;
    cell.tupian.image = [UIImage imageNamed:model.image_person1];
    cell.leixing.text = model.inforType;
    cell.detail.text = model.inforResult;
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
